import { request } from "@/utils/service"
import type * as Combo from "./types/combo"
import { getToken } from "@/utils/cache/cookies"
/** 增 */
export function createComboDataApi(data: Combo.ICreateComboRequestData) {
  return request({
    url: "order/package/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteComboDataApi(id: string) {
  return request({
    url: "order/package/del",
    method: "delete",
    params: {
      id
    }
  })
}

/** 改 */
export function updateComboDataApi(data: Combo.IUpdateComboRequestData) {
  return request({
    url: "order/package/update",
    method: "put",
    data
  })
}

/** 查 */
export function getComboDataApi(params: Combo.IGetComboRequestData) {
  return request<Combo.GetComboResponseData>({
    url: "order/package/query",
    method: "get",
    params
  })
}
/**图片上传 */
export function uploadComboImageList(data: any) {
  return request({
    url: "/h5Package/upload",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}

/** 根据套餐/产品id查询详情 */
export function getComboDetail(data: any) {
  return request<any>({
    url: "order/package/api/queryId",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data"
    },
    data
  })
}

//查所有套餐不带message字段
export function getComboDataApi1(params: any) {
  return request<Combo.GetComboResponseData>({
    url: "/order/package/queryAll",
    method: "get",
    params
  })
}
//查分销商套餐不带message字段
export function getComboDataApi2(params: any) {
  return request<Combo.GetComboResponseData>({
    url: "/order/package/queryAllByOnpe",
    method: "get",
    params
  })
}
/**合集套餐 */
export function getCompailationDataApi(params: any) {
  return request({
    url: "/order/packageHeJi/query",
    method: "get",
    params
  })
}
export function getCompilationChildApi(params: any) {
  return request({
    url: "/order/packageHeJiInfo/query",
    method: "get",
    params
  })
}
/**佣金及分销商可见相关接口 */
/**获取配置信息 */
export function getUserAndRule(params: any) {
  return request({
    url: "/order/packageRolesType/query",
    method: "get",
    params
  })
}
/**新增对分销商可见配置 */
export function createOpenUser(data: any) {
  return request({
    url: "/order/packageRolesType/update",
    method: "post",
    data
  })
}
/**新增佣金规则 */
export function addRules(data: any) {
  return request({
    url: "/order/packageCommission/add",
    method: "post",
    data
  })
}
/**修改佣金规则 */
export function editRules(data: any) {
  return request({
    url: "/order/packageCommission/update",
    method: "post",
    data
  })
}
/**删除佣金规则 */
export function delRules(id: any) {
  return request({
    url: `/order/packageCommission/del/${id}`,
    method: "get"
  })
}
/**查询佣金规则 未设置的分销商 */
export function queryNoSet(params: any) {
  return request({
    url: "/order/packageCommission/commissionUser",
    method: "get",
    params
  })
}
/**查看下级佣金变更记录 */
export function queryUnder(params: any) {
  return request({
    url: "/order/packageCommissionLog/query",
    method: "get",
    params
  })
}
